package com.hgy.carsb.controller;


import com.hgy.carsb.entity.BenefitDetail;
import com.hgy.carsb.service.BenefitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class BenefitController {


    @Autowired
    private BenefitService benefitService;

    private int year = 2020;
    private int month = 4;

    @GetMapping("/benefit")
    public List<BenefitDetail> getDetail(){
        List<BenefitDetail> list = new ArrayList<>();
        String[] code = {"income", "princome", "prcost", "prtax",
                        "printerest", "otincome", "otcost",
                        "otinterest", "marketingcost", "msalary", "freight", "promotion", "quality", "propaganda", "advertising",
                                        "management", "maintenance", "technology", "intangible", "research", "msalary",
                                        "financialcost", "interestin", "interestout", "exchhange",
                        "totalfee", "deasset", "fairvalue", "invest", "opprofit", "otin", "otout",
                        "interest"};
        for (int i=0; i<code.length; i++){
            list.add(benefitService.getDetail(year, month, code[i], "FAW"));
        }
        return list;
    }
}
